#!/usr/bin/node

const Koa = require('koa');
const task = require('./lib/task.js');
const app = new Koa();

// M-logger中间件
var logger = require('./middleware/logger.js');
app.use(logger);
//app.use((ctx, next) => {    //M-logger
  //parse req
  //console.log(`${ctx.method} ${ctx.url}`);
  //const start = new Date();
  //next();
  //const end = new Date();
  //console.log(ctx.method);
  //console.log(end-start);
//});

app.use(async(ctx, next) => {     //M-hello
  ctx.body = 'hello koa! tesk cost: ' + await task() + 'ms..';

});

app.listen(8080);
console.log('hello world');


